import { FileStat, FileType, Uri } from 'vscode';
import { GlobalConst } from '../../../constants';

export abstract class SystemFileStat implements FileStat {
  ctime: number = Date.now();

  mtime: number = Date.now();

  size: number = 0;

  /**
   * 文件路径
   *
   * @author chitanda
   * @date 2021-11-30 12:11:03
   * @readonly
   * @type {string}
   */
  get path(): string {
    return this.content.path;
  }

  /**
   * 全路径，为文件时有用
   *
   * @author chitanda
   * @date 2021-12-07 10:12:04
   * @readonly
   * @type {string}
   */
  get fullPath(): string {
    return this.path;
  }

  /**
   * 文件名称
   *
   * @author chitanda
   * @date 2021-11-30 12:11:11
   * @readonly
   * @type {string}
   */
  get name(): string {
    return this.content.name;
  }

  constructor(
    public readonly content: { name: string; path: string },
    readonly type: FileType,
  ) {}

  /**
   * 获取 uri
   *
   * @author chitanda
   * @date 2021-11-30 12:11:32
   * @return {*}  {Uri}
   */
  getUri(): Uri {
    return Uri.parse(`${GlobalConst.FS_PROTOCOL.SYSTEM}${this.fullPath}`);
  }
}
